import http from './http' // 导入已配置的 axios 实例

console.log(http)

// GET请求：获取博客评论
export async function getBlogComments<T>(blogId: string): Promise<T> {
  try {
    return await http.get<T>(`/api/blogs/${blogId}/comments`)
  } catch (error) {
    throw error
  }
}

// POST请求：添加评论
export async function addComment<T>(
  blogId: string,
  data: Record<string, any>
): Promise<T> {
  try {
    return await http.post<T>(`/api/blogs/${blogId}/comments`, data)
  } catch (error) {
    throw error
  }
}

// DELETE请求：删除评论
export async function deleteComment<T>(commentId: string): Promise<T> {
  try {
    return await http.delete<T>(`/api/comments/${commentId}`)
  } catch (error) {
    throw error
  }
}

// PUT请求：编辑评论
// export async function editComment<T>(
//   blogId: string,
//   commentId: string,
//   data: Record<string, any>
// ): Promise<T> {
//   try {
//     return await http.put<T>(`/api/blogs/${blogId}/comments/${commentId}`, data)
//   } catch (error) {
//     throw error
//   }
// }

// 其他评论相关请求可以继续在此文件中添加
